package com.ruoyi.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.project.domain.entity.Project;
import com.ruoyi.project.domain.query.PhaseDictionaryQuery;
import com.ruoyi.project.domain.query.ProjectQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface ProjectMapper extends BaseMapper<Project> {
    List<Project> getList(ProjectQuery query);

    List<Project> getSaleListPage(ProjectQuery query);

    @Select("  SELECT\n" +
            "        d.*,p.*\n" +
            "        FROM\n" +
            "        project d\n" +
            "        JOIN project_phase p ON d.project_no = p.project_no\n" +
            "        WHERE\n" +
            "        d.del_flag = 0\n" +
            "        AND p.del_flag = 0\n" +
            "        and p.phase_id = 5\n" +
            "        and p.status = 1\n")
    List<Project> getAccountingList();
    //查询最大项目编号
    @Select("SELECT MAX(project_no) FROM project WHERE project_no LIKE CONCAT(#{prefix}, '%')")
    String findMaxProjectNo(@Param("prefix") String prefix);

    @Select("SELECT MAX(c.company_no) FROM project c WHERE c.company_no LIKE CONCAT(#{prefix}, '%') and del_flag = '0'")
    String findMaxCodeByPrefix(@Param("prefix") String prefix);

}
